﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>NGINX Throttle Violations</title>

    <script src="http://soapi.info/code/js/stable/scripts/Soapi.js" type="text/javascript"></script>

    <script type="text/javascript">

        var apiKey = 'qgAq_KfDu0KYzlNG-qaTuw';



        // default will be set to 170 in next release
        Soapi.RequestQueue.setInterval(170); // 30 per 5 sec = 6 per sec = interval 166.6 ms

        // see http://stackapps.com/questions/1143/request-throttling-limits


        // get a bunch of associations from stackauth
        window.setTimeout(function()
        {
            Soapi.RouteFactory("api.stackoverflow.com", apiKey)
            .Users({ pagesize: 100, page: 1 })
            .getResponse(function(data)
            {
                for (var i = 0; i < data.items.length; i++)
                {
                    var id = data.items[i].association_id;

                    if (id)
                    {
                        Soapi.RouteFactory("", apiKey)
                        .UsersByIdAssociated(id)
                        .getResponse();
                    }
                };
            });
        }, 100);

        window.setTimeout(function()
        {
            // get a bunch of tags from meta at the same time - all should be queued and executed with no error

            Soapi.RouteFactory("api.meta.stackoverflow.com", apiKey)
            .Tags({ pagesize: 1 })
            .getPagedResponse();

        }, 10);
    </script>

</head>
<body>
</body>
</html>
